home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Hot Mix 17
/
Hot Mix 17.iso
/
HM17_SGI
/
research
/
examples
/
demo
/
demosrc
/
d_volrendr.pro
< prev
next >
Wrap
Text File
|
1997-07-08
|
54KB
|
1,604 lines
; $Id: d_volrendr.pro,v 1.31 1997/04/25 22:46:18 tremblay Exp $
;
; Copyright (c) 1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;
;+
; FILE:
; d_volrendr.pro
;
; CALLING SEQUENCE: d_volrendr
;
; PURPOSE:
; Shows the volume rendering techniques.
;
; MAJOR TOPICS: Visualization and data processing.
;
; CATEGORY:
; IDL 5.0
;
; INTERNAL FUNCTIONS and PROCEDURES:
; pro add_Table - Create a list of widget buttons
; pro set_Table - Set the opacity table list
; fun load_Volume - Read the volume data set
; fun toggle_State - Toggle the on/off name
; pro volrendr_Event - Event handler
; pro volrendr_Cleanup - Cleanup
; pro d_volrendr - Main procedure
; EXTERNAL FUNCTIONS, PROCEDURES, and FILES:
; pro trackball__define - Create the trackball object
; volrendr.txt
; 16cols.pal
; banded.pal
; bess.pal
; gray.pal
; solid.pal
; voxel.pal
; bess.opa
; layer.opa
; voxel.opa
;
; REFERENCE: IDL Reference Guide, IDL User's Guide
;
; NAMED STRUCTURES:
; none.
;
; COMMON BLOCS:
; none.
;
; MODIFICATION HISTORY: Written by RF, RSI, 1996
; Modified by DAT,RSI, 1996 New GUI
;
;-
;----------------------------------------------------------------------------
;
; PURPOSE Add a table list to the options (buttons)
;
pro Add_Tables, $
wild, $ ; IN: wild card character ex: *.opa
wid, $ ; IN: Parent widget id. New button will be childs.
uval, $ ; IN: user value assigned to the created buttons.
list, $ ; OUT: list all the file found
widgetList ; OUT: created widget button IDs
; Go to the current directory.
;
cd, cur=cur
; Go to the directory that has all the table files.
;
cd, filepath('', SUBDIR=['examples','demo','demodata'])
; Find all the file that ends by the characters spuecified
; by 'wild' .
;
list=findfile(wild)
szlist = size(list)
; filepath under VMS always returns full path
; this must be removed
;
if (!VERSION.OS_FAMILY EQ 'vms') then begin
for i=0, n_elements(list)-1 do begin
bracketPos = RSTRPOS(list[i],']')
if (bracketPos GE 0) then begin
list[i]=strmid(list[i], bracketPos+1, $
STRLEN(list[i])-bracketPos-1)
endif
semicolonPos = STRPOS(list[i],';')
if (semicolonPos GE 0) then begin
list[i]=strmid(list[i], 0, semicolonPos)
endif
endfor
endif
; Create a widget button for each file. Make the widget button
; to be the child of 'wid', and the uservalue is 'uval'.
;
widgetList = LONARR(szlist(1))
for i=0,n_elements(list)-1 do begin
widgetList(i)=WIDGET_BUTTON(wid, VALUE=list(i), UVALUE=uval)
end
; Return to previous directory.
;
cd, cur
end
;----------------------------------------------------------------------------
;
; PURPOSE Set the color or opacity table.
;
pro Set_Table, $
oVolume, $ ; IN: volume object
widgetID, $ ; IN: button widget ID
which ; IN: table type. 0=color, 1= opacity
; Get the button value which is the filename.
;
WIDGET_CONTROL, widgetID, GET_VALUE=filename
; Read the table(color or opacity).
;
GET_LUN, lun
newTable = BYTARR(256,3)
OPENR, lun, filepath(filename, $
SUBDIR=['examples','demo','demodata'])
READU, lun, newTable
CLOSE, lun
FREE_LUN,lun
; Branch to the case of color (0) or opacity table(1).
; Then set the object property to that table.
;
case which of
; Set the RGB color table.
;
0 : begin
oVolume->SetProperty, RGB_TABLE0=newTable
end ; of 0
; Set the opacity table.
;
1 : begin
oVolume->SetProperty, OPACITY_TABLE0=newTable(*,0)
end ; of 1
endcase
end ; of Set_Table
;----------------------------------------------------------------------------
;
; PURPOSE Set the the color or opacity table.
;
function load_volume, $
which, $ ; String identifying which volume to load.
parentModel ; Parent model of the newly created volume object.
; Get a lun.
;
GET_LUN,lun
; Branch to the appropriate volume.
;
case which of
; Load the heart volume.
;
'Heart': begin
data = BYTARR(202,132,144)
OPENR, lun, filepath('heart.bin', $
SUBDIR=['examples','demo','demodata'])
READU, lun,data
CLOSE, lun
; Make the solid palette color table the default.
;
colors = BYTARR(256,3, /NOZERO)
OPENR, lun, filepath('solid.pal', $
SUBDIR=['examples','demo','demodata'])
READU, lun, colors
CLOSE,lun
; Make the solid opacity table the default.
;
opac = BYTARR(256, /NOZERO)
OPENR, lun, filepath('solid.opa', $
SUBDIR=['examples','demo','demodata'])
READU, lun, opac
CLOSE, lun
zc = 1.0
end ; of Heart
; Load the brain volume.
;
'Brain': begin
; Read the brain data.
;
data = BYTARR(148,156,108, /NOZERO)
if 0 then begin ;Old way
OPENR, lun, filepath('brain.bin', $
SUBDIR=['examples','demo','demodata'])
READU, lun, data
ENDIF ELSE BEGIN ;Read compressed data
OPENR, lun, filepath('brain.gif', $
SUBDIR=['examples','demo','demodata'])
DECODE_GIF, Lun, Data
ENDELSE
CLOSE, lun
; Make the voxel palette color table the default.
;
colors = BYTARR(256,3, /NOZERO)
OPENR, lun, filepath('voxel.pal', $
SUBDIR=['examples','demo','demodata'])
READU, lun, colors
CLOSE, lun
; Make the voxel opacity table the default.
;
opac = BYTARR(256, /NOZERO)
OPENR,lun, filepath('voxel.opa', $
SUBDIR=['examples','demo','demodata'])
READU, lun, opac
CLOSE, lun
zc = 1.5/0.9375
end ; of Brain
; Load the Bessel volume.
;
'Bessel': begin
; Create the bessel data, the opacity and the color
; tables.
;
z = FLTARR(40,40,20, /NOZERO)
x = SHIFT(DIST(40), 20, 20)
for i = 0, 19 do z(*,*,i)=BESELJ(x/2, i)
data=BYTARR(40,40,20)
data=BYTE(((z+0.4)/1.4)*255)
opac = BYTARR(256)
opac = BINDGEN(256)/4
colors = BYTARR(256,3)
colors(*,*) =0
colors(*,1) = BINDGEN(256)
zc = 1.0
end ; of Bessel
endcase ; of which
; Create the volume object.
;
FREE_LUN,lun
; Set up XYZcoord_conv to center and scale the volume.
;
i = SIZE(data)
m = FLOAT(max(i[1:3]))
sx = 1.0/m
sy = 1.0/m
sz = (1.0/m)*zc
ox = -(float(i[1])*sx)*0.5
oy = -(float(i[2])*sy)*0.5
oz = -(float(i[3])*sz)*0.5
oVolume = OBJ_NEW('IDLgrVolume',data, $
xcoord_conv=[ox, sx], $
ycoord_conv=[oy, sy], $
zcoord_conv=[oz, sz] $
)
oVolume->SetProperty, opacity_table0=opac, $
/ZERO_OPACITY_SKIP, $
RGB_TABLE0=colors,HIDE=1
oVolume->SetProperty, /ZBUFFER
parentModel->Add, oVolume
if (which EQ 'Heart') then begin
oVolume->SetProperty, AMBIENT=[130,130,130]
endif
; Return the volume object.
;
RETURN, oVolume
end ; load_volume
;----------------------------------------------------------------------------
;
; PURPOSE Toggle the buton state between off and on.
;
function Toggle_state, $
widgetID ; IN: button widget identifer.
WIDGET_CONTROL, widgetID, GET_VALUE=name
s = STRPOS(name,'(off)')
if (s NE -1) then begin
STRPUT, name, '(on )', s
ret = 1
endif else begin
s = STRPOS(name,'(on )')
STRPUT, name, '(off)', s
ret = 0
endelse
WIDGET_CONTROL, widgetID, SET_VALUE=name
RETURN, ret
end
;----------------------------------------------------------------------------
;
; PURPOSE Toggle the buton state between off and on.
;
pro volrendr_event, $
sEvent ; IN: event structure.
if (TAG_NAMES(sEvent, /STRUCTURE_NAME) EQ $
'WIDGET_KILL_REQUEST') then begin
WIDGET_CONTROL, sEvent.top, /DESTROY
RETURN
endif
; Get the event user value.
;
WIDGET_CONTROL, sEvent.id, GET_UVALUE=uval
; Branch to the correct event user value.
;
case uval of
; CHange the color table.
;
'COLOR_TAB' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
Set_Table, state.oVolumeArray(state.cur), sEvent.id, 0
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 0
; Set isDrawn to 0 to avoid redrawing again (no expose event).
;
state.isDrawn = 0
WIDGET_CONTROL, sEvent.id, GET_VALUE=evvalue, /NO_COPY
sizewidget = size(state.colorWidgetID)
for i = 0, sizeWidget(1)-1 do begin
WIDGET_CONTROL, state.colorWidgetID(i), GET_VALUE=widgetValue
WIDGET_CONTROL, state.colorWidgetID(i), SENSITIVE=1
if (widgetValue EQ evvalue) then begin
WIDGET_CONTROL, state.colorWidgetID(i), SENSITIVE=0
endif
endfor
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of COLOR_TAB
; Change to a new opacity table.
;
'OPACITY_TAB' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
Set_Table, state.oVolumeArray(state.cur), sEvent.id, 1
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
; Opcaity table does not create an expose event.....
; Therefore set isDrawn to 0.
;
state.isDrawn = 0
WIDGET_CONTROL, sEvent.id, GET_VALUE=evvalue, /NO_COPY
sizewidget = SIZE(state.opacityWidgetID)
for i = 0, sizeWidget(1)-1 do begin
WIDGET_CONTROL, state.opacityWidgetID(i), GET_VALUE= widgetValue
WIDGET_CONTROL, state.opacityWidgetID(i), SENSITIVE=1
if (widgetValue EQ evvalue) then begin
WIDGET_CONTROL, state.opacityWidgetID(i), SENSITIVE=0
endif
endfor
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of OPACITY_TAB
; Render the image and display it.
;
'RENDER' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
WIDGET_CONTROL,sEvent.top, /HOURGLASS
state.oWindow->SetProperty, QUALITY=2
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw,state.oView
state.isDrawn = 1
WIDGET_CONTROL, state.wBase, SENSITIVE=1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of RENDER
; Compute the MIP rendering technique and display the result.
;
'SMIP': begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
j = Toggle_State(sEvent.id)
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, COMPOSITE_FUNCTION=j
endfor
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of SMIP
; Handle the Left Mouse Button SCALE of the volume.
;
'LMBSCALE': begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
state.LMBscale = Toggle_State(sEvent.id)
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of LMBSCALE
; Set on or off the auto rendering property.
;
'AUTORENDER' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
state.autoR = Toggle_State(sEvent.id)
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of AUTORENDER
; Select a volume to display.
;
'VOLSEL': begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
; Hide the annnotation text (all 3).
;
for i=3,5 do state.oOtherObjectArray(i)->SetProperty, HIDE=1
state.oVolumeArray(state.cur)->GetProperty, RGB_TABLE0=curColorTable
state.oVolumeArray(state.cur)->GetProperty, $
OPACITY_TABLE0=curOpacityTable
case sEvent.value of
; Show the brain.
;
0: begin
state.oVolumeArray(0)->SetProperty, HIDE=0
state.oVolumeArray(1)->SetProperty, HIDE=1
state.oOtherObjectArray(4)->SetProperty, HIDE=0
end
; Show the bessel function.
;
1: begin
state.oVolumeArray(0)->SetProperty, HIDE=1
state.oVolumeArray(1)->SetProperty, HIDE=0
state.oOtherObjectArray(5)->SetProperty, HIDE=0
end
endcase
state.cur = sEvent.value
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, $
RGB_TABLE0=curColorTable
state.oVolumeArray(i)->SetProperty, $
OPACITY_TABLE0=curOpacityTable
endfor
; Redraw the volume.
;
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of VOLSEL
; Turn on or off the lights.
;
'LIGHTING': begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
j = Toggle_State(sEvent.id)
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, LIGHTING_MODEL=j
endfor
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
; Redraw the volume.
;
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of LIGHTING
; Add (or remove) the wire box object.
;
'WIREBOX' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
j = Toggle_State(sEvent.id)
; oOtherObjectArray(0) is the wire box object.
; Hide or show it.
;
state.oOtherObjectArray(0)->SetProperty, HIDE=1-j
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of WIREBOX
; Add or remove the solid plane object.
;
'SOLIDPLANE' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
j = Toggle_State(sEvent.id)
; oOtherObjectArray(1) is the solid plane object.
; Hide or show it.
;
state.oOtherObjectArray(1)->SetProperty, HIDE=1-j
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of SOLIDPLANE
; Add or remove the (3 axes) object.
;
'AXES' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
j = Toggle_State(sEvent.id)
; oOtherObjectArray(2) is the axes object.
; Hide or show it.
;
state.oOtherObjectArray(2)->SetProperty,HIDE=1-j
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of AXES
; Set the render step to 111.
;
'RENDERSTEP111' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
step = [1,1,1]
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, RENDER_STEP=step
endfor
WIDGET_CONTROL, state.wRenderStep111Button, SENSITIVE=0
WIDGET_CONTROL, state.wRenderStep112Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep114Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep221Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep222Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep444Button, SENSITIVE=1
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
state.renderStepFlag = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of RENDERSTEP111
; Set the render step to 112.
;
'RENDERSTEP112' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
step = [1,1,2]
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, RENDER_STEP=step
endfor
WIDGET_CONTROL, state.wRenderStep111Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep112Button, SENSITIVE=0
WIDGET_CONTROL, state.wRenderStep114Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep221Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep222Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep444Button, SENSITIVE=1
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
state.renderStepFlag = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of RENDERSTEP112
; Set the render step to 114.
;
'RENDERSTEP114' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
step = [1,1,4]
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, RENDER_STEP=step
endfor
WIDGET_CONTROL, state.wRenderStep111Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep112Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep114Button, SENSITIVE=0
WIDGET_CONTROL, state.wRenderStep221Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep222Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep444Button, SENSITIVE=1
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
state.renderStepFlag = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of RENDERSTEP114
; Set the render step to 221.
;
'RENDERSTEP221' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
step = [2,2,1]
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, RENDER_STEP=step
endfor
WIDGET_CONTROL, state.wRenderStep111Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep112Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep114Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep221Button, SENSITIVE=0
WIDGET_CONTROL, state.wRenderStep222Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep444Button, SENSITIVE=1
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
state.renderStepFlag = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of RENDERSTEP221
; Set the render step to 222.
;
'RENDERSTEP222' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
step = [2,2,2]
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, RENDER_STEP=step
endfor
WIDGET_CONTROL, state.wRenderStep111Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep112Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep114Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep221Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep222Button, SENSITIVE=0
WIDGET_CONTROL, state.wRenderStep444Button, SENSITIVE=1
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
state.renderStepFlag = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of RENDERSTEP222
; Set the render step to 222.
;
'RENDERSTEP444' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
step = [4,4,4]
for i = 0, N_ELEMENTS(state.oVolumeArray)-1 do begin
state.oVolumeArray(i)->SetProperty, RENDER_STEP=step
endfor
WIDGET_CONTROL, state.wRenderStep111Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep112Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep114Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep221Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep222Button, SENSITIVE=1
WIDGET_CONTROL, state.wRenderStep444Button, SENSITIVE=0
if (state.autoR EQ 0 ) then begin
state.oWindow->SetProperty, QUALITY=0
endif else begin
state.oWindow->SetProperty, QUALITY=2
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
state.isDrawn = 1
state.renderStepFlag = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of RENDERSTEP444
; Perform the depth queuing.
; This portion of the code is commented out
; because this option is not offered but it
; is provided for the user benefit.
;
; 'DEPTHQ': begin
; WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
; j = Toggle_State(sEvent.id)
; case j of
;
; 1 : begin
; for i=0,2 do begin
; state.oVolumeArray(i)->SetProperty,Depth_Queue=[-0.4,0.8]
; endfor
; end
;
; 0 : begin
; for i=0,2 do begin
; state.oVolumeArray(i)->SetProperty,Depth_Queue=[0,0]
; endfor
; end
; endcase
;
; state.oWindow->Draw, state.oView
; WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
; end ; of DEPTHQ
;
; Handle the event that occur in the drawing area.
;
'DRAW': begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
; Expose.
;
if (sEvent.type eq 4) then begin
if (state.initial EQ 1) then begin
if (state.isDrawn EQ 0) then begin
if (state.renderStepFlag EQ 1) then begin
state.renderStepFlag = 0
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
RETURN
endif
if (state.autoR EQ 1) then begin
state.oWindow->SetProperty, QUALITY=2
endif else begin
state.oWindow->SetProperty, QUALITY=0
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
endif ; of isDrawn = 0
endif ; of initial = 1
state.initial = 1
endif ; of event type = 4
; Set the isDrawn flag to 0 ( object not drawn)
;
state.isDrawn = 0
; Handle trackball update. Rotate the top models
; oModelArray(0) and oModelArray(1)
;
bHaveTransform = state.oTrack->Update(sEvent, TRANSforM=qmat )
if (bHaveTransform NE 0) then begin
state.oModelArray(0)->GetProperty, TRANSforM=t
mt = t # qmat
state.oModelArray(0)->SetProperty, TRANSforM=mt
state.oModelArray(1)->SetProperty, TRANSforM=mt
endif
; Handle the button press event.
;
if (sEvent.type EQ 0) then begin
if ((sEvent.press EQ 1) AND (state.LMBscale EQ 1)) $
then sEvent.press = 2
if (sEvent.press EQ 2) then begin
; Scale the objects.
;
xy = ([sEvent.x, sEvent.y] - state.center)
r= TOTAL(xy^2) ; distance from center of unit circle
state.sc(1) = SQRT(r)
state.sc(2) = 1.0
end else if (sEvent.press EQ 4) then begin ; right mouse button
; Pick a voxel point.
;
j = state.oVolumeArray(state.cur)->pickvoxel(state.oWindow, $
state.oView,[sEvent.x, sEvent.y])
k = -1
if (j(0) NE -1) then begin
state.oVolumeArray(state.cur)->GetProperty, $
DATA0=dd, /NO_COPY
k = dd(j(0),j(1),j(2))
state.oVolumeArray(state.cur)->SetProperty, $
DATA0=dd, /NO_COPY
endif
state.btndown = 4
; Display the point coordinates and its value.
;
str = string(j(0),j(1),j(2),k, $
FORMAT='("X=",I3.3,",Y=",I3.3,",Z=",I3.3,",Value=",I3.3)')
state.sText.text[6] = str
textChange = ['coord']
putTips, state.sText, state.wText[1], $
textChange, [2]
endif
state.btndown = sEvent.press
if (sEvent.press NE 4) then begin
state.oWindow->SetProperty, QUALITY=0
endif
WIDGET_CONTROL,state.wDraw, /DRAW_MOTION
endif
; Handle the button motion.
;
if ((sEvent.type eq 2) and $
(state.btndown eq 4)) then begin
j = state.oVolumeArray(state.cur)->pickvoxel(state.oWindow, $
state.oView,[sEvent.x,sEvent.y])
k= -1
if (j(0) NE -1) then begin
state.oVolumeArray(state.cur)->GetProperty, DATA0=dd, /NO_COPY
k = dd(j(0), j(1), j(2))
state.oVolumeArray(state.cur)->SetProperty, DATA0=dd, /NO_COPY
endif
; Display the voxel location and value.
;
str = string(j(0),j(1),j(2),k, $
FORMAT='("X=",I3.3,",Y=",I3.3,",Z=",I3.3,",Value=",I3.3)')
state.sText.text[6] = str
textChange = ['coord']
putTips, state.sText, state.wText[1], $
textChange, [2]
endif else if ((sEvent.type eq 2) and $
(state.btndown eq 2)) then begin
xy = ([sEvent.x,sEvent.y] - state.center)
r = total(xy^2) ; distance from center of unit circle
state.sc(2) = (SQRT(r)/state.sc(1))/state.sc(2)
state.oModelArray(1)->Scale, state.sc(2), state.sc(2), state.sc(2)
state.oModelArray(0)->Scale, state.sc(2), state.sc(2), state.sc(2)
state.sc(2) = (SQRT(r)/state.sc(1))
state.oWindow->Draw, state.oView
endif else if ((sEvent.type EQ 2) and $
(state.btndown EQ 1)) then begin
if (bHaveTransform) then begin
state.oWindow->Draw, state.oView
endif
endif
; Handle the button release.
;
if (sEvent.type eq 1) then begin
if (state.btndown EQ 1) then begin
; do nothing for left mouse button.
endif else if (state.btndown EQ 2) then begin
state.sc(0) = state.sc(2)*state.sc(0)
endif else if (state.btndown EQ 4) then begin
j = state.oVolumeArray(state.cur)->pickvoxel(state.oWindow, $
state.oView,[sEvent.x,sEvent.y])
k = -1
if (j(0) NE -1) then begin
state.oVolumeArray(state.cur)->GetProperty, $
DATA0=dd, /NO_COPY
k = dd(j(0),j(1),j(2))
state.oVolumeArray(state.cur)->SetProperty, $
DATA0=dd, /NO_COPY
; Get the volume coord form.
;
state.oVolumeArray(state.cur)->GetProperty, $
XCOORD_CONV=x_conv, $
YCOORD_CONV=y_conv, ZCOORD_CONV=z_conv
; Convert to normal coordinates.
;
jack = FLTARR(3)
jack(0) = x_conv(1)*j(0) + x_conv(0)
jack(1) = y_conv(1)*j(1) + y_conv(0)
jack(2) = z_conv(1)*j(2) + z_conv(0)
; If the bessel obj, apply the bessel zoom.
;
if (state.cur EQ 2) then jack = jack*4.5
; Apply the difference.
;
state.oOtherObjectArray(6)->Translate, $
jack(0)-state.jpos(0), $
jack(1)-state.jpos(1), jack(2)-state.jpos(2)
; Store the new location.
;
state.jpos = jack
endif
; Display the voxel location and value.
;
str = string(j(0),j(1),j(2),k, $
FORMAT='("X=",I3.3,",Y=",I3.3,",Z=",I3.3,",Value=",I3.3)')
state.sText.text[6] = str
textChange = ['coord']
putTips, state.sText, state.wText[1], $
textChange, [2]
endif
if (state.autoR EQ 1) then begin
state.oWindow->SetProperty, QUALITY=2
endif
if ((state.btndown NE 4) OR (state.autoR EQ 1)) then begin
if (state.autoR EQ 1) then begin
state.oWindow->SetProperty, QUALITY=2
endif else begin
state.oWindow->SetProperty, QUALITY=0
endelse
WIDGET_CONTROL, state.wBase, SENSITIVE=0
state.oWindow->Draw, state.oView
WIDGET_CONTROL, state.wBase, SENSITIVE=1
endif
state.btndown = 0
WIDGET_CONTROL, state.wDraw, DRAW_MOTION=0
endif ; of event.type = 1
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of DRAW
; Quit this application.
;
'QUIT' : begin
WIDGET_CONTROL, sEvent.top, /DESTROY
end ; of QUIT
'ABOUT' : begin
WIDGET_CONTROL, sEvent.top, GET_UVALUE=state, /NO_COPY
state.isdrawn = 0
; Verify that there is only one instance.
;
if (Xregistered('XDisplayFile') EQ 0) then begin
XDisplayFile, filepath("volrendr.txt", $
SUBDIR=['examples','demo','demotext']), $
DONE_BUTTON='Done', $
TITLE="Volume", $
GROUP=sEvent.top, WIDTH=55, HEIGHT=14
endif
WIDGET_CONTROL, sEvent.top, SET_UVALUE=state, /NO_COPY
end ; of ABOUT
endcase
end
;----------------------------------------------------------------------------
;
; Purpose: Destroy the top objects and restore the previous
; color table.
;
pro volrendr_Cleanup, $
wTopBase ; IN: top level base identifier
WIDGET_CONTROL, wTopBase, GET_UVALUE=state, /NO_COPY
; Destroy the top objects.
;
OBJ_DESTROY, state.oView
OBJ_DESTROY, state.oTrack
OBJ_DESTROY, state.oText
OBJ_DESTROY, state.oFont
OBJ_DESTROY, state.Font24
OBJ_DESTROY, state.oContainer
; Restore the color table.
;
TVLCT, state.colorTable
if widget_info(state.groupBase, /valid) then $
widget_control, state.groupBase, /map
end ; of orbit_Cleanup
;----------------------------------------------------------------------------
;
; Purpose: Perform volume rendering.
;
pro d_volrendr, $
GROUP=group, $ ; IN: (opt) group identifier
APPTLB = appTLB ; OUT: (opt) TLB of this application
; Check the validity of the group identifier
;
ngroup = N_ELEMENTS(group)
if (ngroup NE 0) then begin
check = WIDGET_INFO(group, /VALID_ID)
if (check NE 1) then begin
print,'Error, the group identifier is not valid'
print, 'Return to the main application'
RETURN
endif
groupBase = group
endif else groupBase = 0L
; Get the current color vectors to restore
; when this application is exited.
;
TVLCT, savedR, savedG, savedB, /GET
; Build color table from color vectors
;
colorTable = [[savedR],[savedG],[savedB]]
; Set up dimensions of the drawing (viewing) area.
;
device, GET_SCREEN_SIZE=scr
xdim = scr(0)*0.6 *0.75
ydim = xdim*0.8 *0.75
; Get the tips.
;
sText = getTips(filepath('volrendr.tip', $
SUBDIR=['examples','demo', 'demotext']) )
; Create widgets.
;
if (N_ELEMENTS(group) EQ 0) then begin
wBase = WIDGET_BASE(/COLUMN, XPAD=0, YPAD=0, $
TITLE="Volumes", $
/TLB_KILL_REQUEST_EVENTS, $
TLB_FRAME_ATTR=1, MBAR=barBase)
endif else begin
wBase = WIDGET_BASE(/column, XPAD=0, YPAD=0, $
TITLE="Volumes", $
GROUP_LEADER=group, $
/TLB_KILL_REQUEST_EVENTS, $
TLB_FRAME_ATTR=1, MBAR=barBase)
endelse
; Create the menu bar. It contains the file|quit,
; edit|shade-style, help|about buttons.
;
fileMenu = WIDGET_BUTTON(barBase, VALUE='File', /MENU)
wQuitButton = WIDGET_BUTTON(fileMenu, VALUE='Quit', UVALUE='QUIT')
; Create the menu bar item Edit that has
; the shade and style options.
;
wOptionButton = WIDGET_BUTTON(barBase, VALUE='Options', /MENU)
wLightButton = WIDGET_BUTTON(wOptionButton, $
VALUE="Gradient Shading (off)", UVALUE='LIGHTING')
; Provide the user the depth queueing code. Not implemented here.
;
; tDepth = WIDGET_BUTTON(wOptionButton, $
; VALUE="Depth Queuing (off)", UVALUE='DEPTHQ')
; Offer the MIP rendering option.
;
wSMIPButton = WIDGET_BUTTON(wOptionButton, $
VALUE="MIP Rendering (off)", UVALUE='SMIP')
; Set on or off the aut rendering option.
;
wAutoRenderButton = WIDGET_BUTTON(wOptionButton, $
VALUE="Auto-Render (off)", UVALUE='AUTORENDER')
; Set the Left Mouse Button for scaling.
;
wLmbButton = WIDGET_BUTTON(wOptionButton, $
VALUE="Left mouse scale (off)", UVALUE='LMBSCALE')
; Add the Color tables list
; the options are contain in the file that end by .pal
;
wPaletteButton = WIDGET_BUTTON(wOptionButton, $
MENU=1, VALUE="Color palette tables", /SEPARATOR)
Add_Tables, '*.pal', wPaletteButton, $
'COLOR_TAB', colorList, colorWidgetID
; Add the opacity options
; The filenames must end by .opa
;
wOpacityButton = WIDGET_BUTTON(wOptionButton, $
MENU=1,VALUE="Opacity Tables")
Add_Tables, '*.opa', wOpacityButton, $
'OPACITY_TAB', opacityList, opacityWidgetID
; Add or remove a wire box object.
;
wWireBoxButton = WIDGET_BUTTON(wOptionButton, $
VALUE="Wire Box (off)", UVALUE='WIREBOX', /SEPARATOR)
; Add or remove a solid plane object.
;
wSolidPlaneButton = WIDGET_BUTTON(wOptionButton, $
VALUE="Solid Plane (off)", UVALUE='SOLIDPLANE')
; Add or remove axes object.
;
wAxesButton = WIDGET_BUTTON(wOptionButton, $
VALUE="Axes (off)", UVALUE='AXES')
; Create the rendering steps options.
;
wRenderStepButton = WIDGET_BUTTON(wOptionButton, $
MENU=1, VALUE="Render step")
wRenderStep111Button = WIDGET_BUTTON(wRenderStepButton, $
VALUE="Step 111", UVALUE='RENDERSTEP111')
wRenderStep112Button = WIDGET_BUTTON(wRenderStepButton, $
VALUE="Step 112", UVALUE='RENDERSTEP112')
wRenderStep114Button = WIDGET_BUTTON(wRenderStepButton, $
VALUE="Step 114", UVALUE='RENDERSTEP114')
wRenderStep221Button = WIDGET_BUTTON(wRenderStepButton, $
VALUE="Step 221", UVALUE='RENDERSTEP221')
wRenderStep222Button = WIDGET_BUTTON(wRenderStepButton, $
VALUE="Step 222", UVALUE='RENDERSTEP222')
wRenderStep444Button = WIDGET_BUTTON(wRenderStepButton, $
VALUE="Step 444", UVALUE='RENDERSTEP444')
; Create the menu bar item help that contains the about button
;
wHelpButton = WIDGET_BUTTON(barBase, VALUE='About', /HELP, /MENU)
wAboutButton = WIDGET_BUTTON(wHelpButton, $
VALUE='About volumes', UVALUE='ABOUT')
; Create a sub base of the top base (wBase)
;
subBase = WIDGET_BASE(wBase, COLUMN=2)
; Create the left Base that contains the functionality buttons
; Notably the object list and the option list
;
wLeftbase = WIDGET_BASE(subBase, /COLUMN)
wVolBGroup = CW_BGROUP(wLeftBase, /COLUMN, $
['Brain','Bessel'], $
/EXCLUSIVE, /NO_REL, /FRAME, UVALUE='VOLSEL', SET_VALUE=0)
; Create the render render button.
;
wRenderButton = WIDGET_BUTTON(wLeftBase, $
VALUE="Render", UVALUE='RENDER', /ALIGN_CENTER)
; Create the right Base that has the drawing area.
;
wRightbase = WIDGET_BASE(subBase, Column = 1)
; Create the drawing area.
;
wDraw = WIDGET_DRAW(wRightBase, $
GRAPHICS_LEVEL=2, $
XSIZE=xdim, YSIZE=ydim, /BUTTON_EVENTS, UVALUE='DRAW', $
RETAIN=0, /EXPOSE_EVENTS)
; Create the status line label.
;
wStatusBase = WIDGET_BASE(wBase, MAP=0, /ROW)
nWidgets = 2
wText = LONARR(nWidgets)
widTips, wStatusBase, sText.text, XSIZE=36, $
YSIZE=3, NWIDGETS=nWidgets, wText
; Realize the base widget.
;
WIDGET_CONTROL, wBase, /REALIZE
WIDGET_CONTROL, /HOURGLASS
; Returns the top level base to the APPTLB keyword.
;
appTLB = wBase
; Size the tips widgets.
;
sizeTips, wBase, wText, wStatusBase
WIDGET_CONTROL, wBase, /CLEAR_EVENTS
WIDGET_CONTROL, wBase, SENSITIVE=0
; Grab the window id of the drawable.
;
WIDGET_CONTROL, wDraw, GET_VALUE=oWindow
; Compute viewplane rect based on aspect ratio.
;
aspect = FLOAT(xdim)/FLOAT(ydim)
myview = [-1.0,-1.0,2,2]
if (aspect > 1) then begin
myview(0) = myview(0) - ((aspect-1.0)*myview(2))/2.0
myview(2) = myview(2) * aspect
endif else begin
myview(1) = myview(1) - (((1.0/aspect)-1.0)*myview(3))/2.0
myview(3) = myview(3) * aspect
endelse
; Create view.
;
oView = OBJ_NEW('idlgrview', PROJECTION=1, EYE=2.0, $
ZCLIP=[1.0,-1.0], VIEWPLANE_RECT=myview,$
COLOR=[0,0,0])
; Create and display the PLEASE WAIT text.
;
oFont = OBJ_NEW('IDLgrFont', 'Helvetica', SIZE=18)
oText = OBJ_NEW('IDLgrText', $
'Starting up Please wait...', $
ALIGN=0.5, $
LOCATION=textLocation, $
COLOR=[255,255,0], FONT=oFont)
; Create model tree.
;
oModelArray = OBJARR(4)
oModelArray(3) = OBJ_NEW('IDLgrModel')
oModelArray(0) = OBJ_NEW('IDLgrModel')
oModelArray(3)->Add, oModelArray(0)
oModelArray(1) = OBJ_NEW('IDLgrModel')
oModelArray(3)->Add, oModelArray(1)
oModelArray(2) = OBJ_NEW('IDLgrModel')
oModelArray(3)->Add, oModelArray(2)
; Add the top model to the view.
;
oView->Add, oModelArray(3)
oModelArray(3)->Add, oText
; Draw the view.
;
;oWindow->Draw, oview
; Load up the volumes.
;
oVolumeArray = OBJARR(2)
oVolumeArray(0) = load_volume('Brain',oModelArray(1))
oVolumeArray(1) = load_volume('Bessel',oModelArray(1))
; Rotate so the Brain looks good...
;
oModelArray(1)->Rotate,[0,1,0],90
oModelArray(0)->Rotate,[0,1,0],90
oModelArray(1)->Rotate,[1,0,0],180
oModelArray(0)->Rotate,[1,0,0],180
; Create other intermixed objects.
;
oOtherObjectArray = OBJARR(7)
; Create a wire box.
;
xp=[-0.25, 0.25, 0.25,-0.25, $
-0.25, 0.25, 0.25,-0.25]
yp=[-0.25,-0.25, 0.25, 0.25, $
-0.25,-0.25, 0.25, 0.25]
zp=[ 0.25, 0.25, 0.25, 0.25, $
-0.25,-0.25,-0.25,-0.25]
pl=[5,0,1,2,3,0, $
5,4,5,6,7,4, $
2,0,4, $
2,1,5, $
2,2,6, $
2,3,7]
oOtherObjectArray(0) = OBJ_NEW('IDLgrpolyline', xp, yp, zp, $
POLYLINES=pl, COLOR=[255,255,255])
oModelArray(0)->Add, oOtherObjectArray(0)
; Create a solid plane.
;
o = 0.3
verts = TRANSPOSE([[-o,o,o,-o],[-o,-o,o,o],[-o,-o,o,o]])
poly = [4,0,1,2,3]
vc = [[0B,255B,0B],[0B,0B,255B],[255B,255B,255B],[255B,0B,0B]]
oOtherObjectArray(1) = OBJ_NEW('IDLgrPolygon', verts, POLYGONS=poly, $
VERT_COLOR=vc, SHADING=1)
oModelArray(0)->Add, oOtherObjectArray(1)
; Create axes
;
xpc = [-1.,1.,0.,0.,0.,0.]
ypc = [0.,0.,-1.,1.,0.,0.]
zpc = [0.,0.,0.,0.,-1.,1.]
plc = [2,0,1,2,2,3,2,4,5]
vcc = [[255B,0B,0B],[255B,0B,0B], $
[0B,255B,0B],[0B,255B,0B], $
[0B,0B,255B],[0B,0B,255B] $
]
oOtherObjectArray(2) = OBJ_NEW('IDLgrpolyline', xpc, ypc, zpc, $
POLYLINES=plc, VERT_COLOR=vcc)
; Something to move the axes with.
;
oOtherObjectArray(6) = OBJ_NEW('idlgrmodel')
oOtherObjectArray(6)->Add, oOtherObjectArray(2)
oModelArray(0)->Add, oOtherObjectArray(6)
; Create a text for information on the objects.
;
font24 = OBJ_NEW( 'IDLgrFont', 'Helvetica', size=18. )
oOtherObjectArray(3) = OBJ_NEW( 'IDLgrText', LOCATION=[10,10], $
'Hog heart, 132x202x144, X-ray CT', COLOR=[255,255,0], $
FONT=font24)
oModelArray(2)->Add, oOtherObjectArray(3)
oOtherObjectArray(4) = OBJ_NEW( 'IDLgrText', LOCATION=[10,10], $
'Human brain, 256x256x124, MRI (T2)', COLOR=[255,255,0], $
FONT=font24,HIDE=1)
oModelArray(2)->Add, oOtherObjectArray(4)
oOtherObjectArray(5) = OBJ_NEW( 'IDLgrText', LOCATION=[10,10], $
'Swept Bessel series, 40x40x20', COLOR=[255,255,0], $
FONT=font24,HIDE=1)
oModelArray(2)->Add, oOtherObjectArray(5)
; Set to thick lines.
;
if (N_elements(thick) NE 0) then begin
oOtherObjectArray(2)->SetProperty, THICK=2.0
oOtherObjectArray(0)->SetProperty, THICK=2.0
end
; Hide the volume objects to start.
;
oOtherObjectArray(0)->SetProperty,HIDE=1
oOtherObjectArray(1)->SetProperty,HIDE=1
oOtherObjectArray(2)->SetProperty,HIDE=1
; Create s lights.
;
vl = OBJ_NEW('IDLgrLight', DIRECTION=[-1,0,1], TYPE=2)
vl->SetProperty, COLOR=[255,255,255], INTENSITY=1.0
oModelArray(3)->Add, vl
sl = OBJ_NEW('IDLgrLight', TYPE=0, INTENSITY=1.0)
oModelArray(3)->Add, sl
; Enable the brain volume.
;
oVolumeArray(0)->SetProperty, HIDE=0
; Set the axes) to not showing.
;
jack = FLTARR(3)
jack = [0.0,0.0,0.0]
; Add the trackball object for interactive change
; of the scene orientation
;
oTrack = OBJ_NEW('Trackball', [xdim/2.0, ydim/2.0], xdim/2.0)
oContainer = OBJ_NEW('IDLgrContainer')
oContainer->Add, oView
oContainer->Add, oTrack
; Initialize the isdrawn flag.
; When isDrawn = 0, it indicates that the object has not
; been drawn yet and the expose event will draw it. When
; isDrawn = 1, it indicates that the object has been drawn
; and that the expose event will skip the drawing command.
;
isDrawn = 1
; Save the state structure.
;
state = { $
center: xdim/2., $ ; X Center of drawing area
radius: ydim/2, $ ; Shpere radius (1/2 of draw area height)
btndown: 0b, $ ; 0= mouse button down, other =not down
pt0: FLTARR(3), $ ; Position point 0
pt1: FLTARR(3), $ ; Position point 1
sc : FLTARR(3), $ ; Scaling factor for x, y, z directions
wDraw: wDraw, $ ; Widget draw ID
oModelArray: oModelArray, $ ; Model array
cur: 0, $ ; Current object shown (0=brain, 1=bessel)
OVolumeArray: $
oVolumeArray, $ ; Volume object array
oOtherObjectArray: $
oOtherObjectArray, $ ; Other objects array
OView: oView, $ ; View object
font24: font24, $
OWindow: oWindow, $ ; Window object
WText: wText, $ ; Widget text IDs for tips
SText: sText, $ ; Text structure for tips
jpos : jack, $ ; Axes position
autoR : 0, $ ; Autorender, 0: off, 1: on
ColorTable: colorTable, $ ; Color table to restore
Initial : 0, $ ; Initial state
OTrack: oTrack, $ ; Trackball object
OText: oText, $ ; Text object
OFont: oFont, $ ; Font object
OContainer: oContainer, $ ; container object
WBase : wBase, $ ; top level base
WRenderStep111Button : $ ; Render step button IDs
wRenderStep111Button, $
WRenderStep112Button : $
wRenderStep112Button, $
WRenderStep114Button : $
wRenderStep114Button, $
WRenderStep221Button : $
wRenderStep221Button, $
WRenderStep222Button : $
wRenderStep222Button, $
WRenderStep444Button : $
wRenderStep444Button, $
ColorWidgetID : $
ColorWidgetID, $ ; Color palette button IDs array
OpacityWidgetID : $
opacityWidgetID, $ ; Opacity table button IDs array
Isdrawn : isDrawn, $ ; 0 =object not drawn, 1 = object drawn
RenderStepFlag : 0, $ ; Render step flag 0= not rendered, 1=is
LMBscale : 0, $ ; Left mouse button scaling mode: 0=not on, 1=on
groupBase: groupBase $ ; Base of Group Leader
}
; Set the scaling factor.
;
state.sc(0) = 1.0
; Set the render step to [ 1, 1, 1,].
;
step=[1,1,1]
oVolumeArray(0)->SetProperty, RENDER_STEP=step
oVolumeArray(1)->SetProperty, RENDER_STEP=step
WIDGET_CONTROL, wRenderStep111Button, SENSITIVE=0
WIDGET_CONTROL, /hourglass
oWindow->SetProperty, QUALITY=2
; Draw the view.
;
Set_Table, state.oVolumeArray(0), colorWidgetID(1), 0
Set_Table, state.oVolumeArray(0), opacityWidgetID(2), 1
; Desensitize the default color and opacity
; ( solid in both cases)
;
WIDGET_CONTROL, colorWidgetID(1), SENSITIVE=0
WIDGET_CONTROL, opacityWidgetID(2), SENSITIVE=0
WIDGET_CONTROL, wBase, SET_UVALUE=state, /NO_COPY
WIDGET_CONTROL, wBase, SENSITIVE=1
oModelArray(3)->Remove, oText
oWindow->Draw, oView
XMANAGER, 'd_volrendr', wBase, Event_Handler='volrendr_event', $
CLEANUP='volrendr_Cleanup'
end ; of d_volrendr.pro